package com.project.communitymanagement.service.impl;

import com.project.communitymanagement.common.BaseServiceImpl;
import com.project.communitymanagement.entity.TbSalaryStructure;
import com.project.communitymanagement.exception.BussinessException;
import com.project.communitymanagement.mapper.TbSalaryStructureMapper;
import com.project.communitymanagement.service.TbSalaryStructureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TbSalaryStructureServiceImpl  extends BaseServiceImpl<TbSalaryStructureMapper, TbSalaryStructure> implements TbSalaryStructureService {

    @Autowired
    private TbSalaryStructureMapper tbsalarystructureMapper;

    @Override
    protected TbSalaryStructureMapper mapper() {
        return tbsalarystructureMapper;
    }

    @Override
    protected TbSalaryStructure defaultModel() {
        return new TbSalaryStructure();
    }

    @Override
    public int save(TbSalaryStructure tbSalaryStructure) {
        int i = tbsalarystructureMapper.getDataByName(tbSalaryStructure.getName());
        if(i > 0)throw new BussinessException ("当前结构名称["+tbSalaryStructure.getName()+"]已存在!");
        return super.save(tbSalaryStructure);
    }

    @Override
    public List<TbSalaryStructure> getAll() {
        return tbsalarystructureMapper.getAll();
    }
}
